<template>
  <div class="p-result common-bg">
    <div class="content">
      <div class="info-box">
        <div class="base-info">
          <span class="title">基础信息</span>
          <el-table :data="baseInfo" style="width: 100%">
            <el-table-column prop="name" label="名称"> </el-table-column>
            <el-table-column prop="code" label="编码"> </el-table-column>
            <el-table-column prop="value" label="值"> </el-table-column>
            <el-table-column prop="remark" label="备注"> </el-table-column>
          </el-table>
        </div>
        <div class="dynamic-info">
          <!-- 动态信息 -->
          <span class="title">动态信息</span>
          <el-table :data="dynamicInfo" style="width: 100%">
            <el-table-column prop="name" label="名称"> </el-table-column>
            <el-table-column prop="code" label="编码"> </el-table-column>
            <el-table-column prop="value" label="值"> </el-table-column>
            <el-table-column prop="remark" label="备注"> </el-table-column>
          </el-table>
        </div>
      </div>
      <div class="rank-box">
        <div class="current-rank">
          <span class="title">当前运动员实时排名</span>
          <el-table :data="currentRank" style="width: 100%">
            <el-table-column prop="AthleteName" label="运动员姓名"> </el-table-column>
            <el-table-column prop="DelegationName" label="代表团名称"> </el-table-column>
            <el-table-column prop="HorseName" label="马名"> </el-table-column>
            <el-table-column prop="HorseBIB" label="马编号"> </el-table-column>
            <el-table-column prop="RoundRank" label="排名"> </el-table-column>
            <el-table-column prop="Time" label="用时"> </el-table-column>
            <el-table-column prop="TotalPunish" label="总罚分"> </el-table-column>
          </el-table>
        </div>
        <div class="rank3">
          <span class="title">前三名</span>
          <el-table :data="rank3" style="width: 100%">
            <el-table-column prop="AthleteName" label="运动员姓名"> </el-table-column>
            <el-table-column prop="DelegationName" label="代表团名称"> </el-table-column>
            <el-table-column prop="HorseName" label="马名"> </el-table-column>
            <el-table-column prop="HorseBIB" label="马编号"> </el-table-column>
            <el-table-column prop="RoundRank" label="排名"> </el-table-column>
            <el-table-column prop="Time" label="用时"> </el-table-column>
            <el-table-column prop="TotalPunish" label="总罚分"> </el-table-column>
          </el-table>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Result',
  props: {
    scoreInfo: {
      type: Object,
      default: () => {},
    },
    baseInfo: {
      type: Array,
      default: () => [],
    },
    dynamicInfo: {
      type: Array,
      default: () => [],
    },
    currentRank: {
      type: Array,
      default: () => [],
    },
    rank3: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      postFlag: 0,
    }
  },
  methods: {
    floorToFixed(num, decimals = 2) {
      const numStr = num.toString()
      const decimalIndex = numStr.indexOf('.')
      if (numStr.length === 0) {
        return '0'
      }
      if (decimalIndex === -1) {
        return num + '.' + '0'.repeat(decimals) // 整数直接补零
      }

      // 直接截取所需小数位
      const truncatedStr = numStr.substring(0, decimalIndex + decimals + 1)
      return parseFloat(truncatedStr).toFixed(decimals)
    },
  },
}
</script>

<style lang="less" scoped>
@import '@/assets/less/result.less';
@import '@/assets/less/common.less';
</style>
